package com.yequan.designpattern.factory;

import com.yequan.designpattern.factory.abstractfactory.ProductFactory;
import com.yequan.designpattern.factory.mulfactory.MulProductFactory;
import com.yequan.designpattern.factory.simplefactory.common.SimpleFactory;
import com.yequan.designpattern.factory.simplefactory.reflect.ReflectFactory;

public class FactoryTest {

    public static void main(String[] args) {
        /**
         * 简单工厂的一般写法
         */
        IProduct1 commonProductA = SimpleFactory.createProduct(SimpleFactory.PRODUCT_A);
        commonProductA.desc1();
        IProduct1 commonProductB = SimpleFactory.createProduct(SimpleFactory.PRODUCT_B);
        commonProductB.desc1();
        /**
         * 简单工厂的反射写法
         */
        IProduct1 reflectProductA = ReflectFactory.createProduct(Product1A.class);
        reflectProductA.desc1();
        IProduct1 reflectProductB = ReflectFactory.createProduct(Product1B.class);
        reflectProductB.desc1();
        /**
         * 多工厂方法创建
         */
        IProduct1 productA = MulProductFactory.createProductA();
        productA.desc1();
        IProduct1 productB = MulProductFactory.createProductB();
        productB.desc1();
        /**
         * 抽象工厂
         */
        ProductFactory productFactory = new ProductFactory();
        productFactory.createProduct1().desc1();
        productFactory.createProduct2().desc2();
    }

}
